package com.mike.employment.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.mike.employment.base.ApiResult;
import com.mike.employment.base.PageRequest;
import com.mike.employment.po.Apply;
import com.mike.employment.service.ApplyService;

@RestController
@RequestMapping("/api/apply")
public class ApplyController {
	
	@Autowired
	private ApplyService applyService;
	
	@PostMapping("/page")
	public ApiResult page(@RequestBody PageRequest req) {
		return ApiResult.success(applyService.getPage(req));
	}
	
	@PutMapping()
	public ApiResult saveOrUpdate(@RequestBody Apply apply) {
		return ApiResult.success(applyService.saveOrUpdate(apply));
	}
	
	@DeleteMapping()
	public ApiResult delete(@RequestBody Long ...ids) {
		return ApiResult.success(applyService.delete(ids));
	}
	
	@GetMapping("/{accountId}/{recruitId}")
	public ApiResult findMyApply(@PathVariable("accountId") Long accountId, @PathVariable("recruitId") Long recruitId) {
		return ApiResult.success(applyService.getMyApply(accountId,recruitId));
	}
}
